app = require('../src/_app')


config = require('./config')
PREFIX_LEN = config.prefix.length


_serve = app.callback()

serve = (req, res)->
    res.constructor.prototype.removeHeader = ->
    res.constructor.prototype.end = (body)->
        @send(body)
    serve = _serve
    _serve(req, res)

module.exports.handler = (req,res,context) ->
    req.path = req.path.slice(PREFIX_LEN)
    req.url = req.url.slice(PREFIX_LEN)
    serve(req, res)
    return
